package web.beans;

import User.bo.UserBo;
import User.model.User;
import util.Context;

/**
 * Created by Новак on 24.11.2014.
 */
public class LoginBean {
    private String login;
    private String pass;
    private UserBean userBean;



    public String doLogin(){
        UserBo userBo= (UserBo) Context.getAppContext().getBean("userBo");
        User user=userBo.getUserByLogin(login,pass);
        if(user!=null){
            userBean.setUserInfo(user);
            return "/index";
        }
        else{
            return "/index";
        }

    }

    //****Вход под User-ом и по Admin-ом
    public String doLoginUser(){

        UserBo userBo= (UserBo) Context.getAppContext().getBean("userBo");
        User user=userBo.getUserByLogin("test1","test1");

            userBean.setUserInfo(user);
        return "/index";
    }
    public String doLoginAdmin(){
        UserBo userBo= (UserBo) Context.getAppContext().getBean("userBo");
        User user=userBo.getUserByLogin("Vanches","Vanches");

            userBean.setUserInfo(user);
        return "/index";
    }
   //********************

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public UserBean getUserBean() {
        return userBean;
    }

    public void setUserBean(UserBean userBean) {
        this.userBean = userBean;
    }
}
